package practica6;

import java.util.LinkedList;
import java.util.List;

import framework.IRule;

public class ReglaAv4 implements IRule<StateB> {

    @Override
    public List<StateB> apply(StateB state) {
	int y = state.posX();
	int x = state.posY();
	List<StateB> states = new LinkedList<StateB>();
	StateB newState1 = new StateB();
	newState1.clone();
	newState1.moveLeft(x, y);
	StateB newState2 = new StateB();
	newState2.clone();
	newState2.moveRigth(x, y);
	if (state.balVaciaIsMiddleInf()) {
	    StateB newState3 = new StateB();
	    newState3.clone();
	    newState3.moveUp(x, y);
	    states.add(newState3);
	} else {
	    StateB newState3 = new StateB();
	    newState3.clone();
	    newState3.moveDown(x, y);
	    states.add(newState3);
	}
	states.add(newState1);
	states.add(newState2);

	return states;
    }

    @Override
    public boolean isApplicable(StateB state) {
	return state.balVaciaIsMiddleInf() || state.balVaciaIsMiddleSup();
    }

}
